% GAUTIER LE BIHAN - 2020
% Replication files for "Shocks vs Menu Costs: Patterns of Price Rigidity in an Estimated Multi-Sector Menu-Cost Model?" Review of Economics and Statistics
%
% Figure P + Table 4
clear;
tic


addpath('..\..\Utilities')  

load actual_moments_k
load res_estim_prodc4n
param0=res_estim_prodc4n

param=   [param0(1) param0(5)  param0(9) ;
           param0(2) param0(6)  param0(10) ;
           param0(3) param0(7)  param0(11);
           param0(4) param0(8)  param0(12)];% 
p0=tanh(param(:,1));
mu_c=param(:,2);
sig_a=exp(param(:,3));
rho_a=ones(4,1)*0.69;

param_a=[p0(1) mu_c(1) sig_a(1) rho_a(1)];
param_m=[p0(2) mu_c(2) sig_a(2) rho_a(2)];
param_s=[p0(3) mu_c(3) sig_a(3) rho_a(3)];
param_e=[p0(4) mu_c(4) sig_a(4) rho_a(4)];

param_med2=[param_a' param_m' param_s' param_e'];

weight_sect2=[0.52; 0.05];
weight_sect2=[0.153; 0.179; 0.188; 0.05];

param_ms(1).param_ms=param_med2;
weight_ms(1).weight_ms=weight_sect2;


s=1;
%stat_mean4=ones(s,6);
for jj=1:s;
    
    param_med=param_ms(jj).param_ms;
    weight_sect=weight_ms(jj).weight_ms;
    p0=param_med(1,:);
    mu_c=param_med(2,:);
    sig_eps_a=param_med(3,:);
    rho_a=param_med(4,:);
    w=weight_sect'
    %[weight_sect(1:2,:);weight_sect(4:6,:)]';
    sm_m=0;
   [avmoments, moments, VC, IRF]=geNCalvoPlus_2Agg(sm_m, p0, mu_c, sig_eps_a, rho_a, w);
 
 moments
  stat_mean4_2019d(jj,:)=[ moments sqrt(VC)]
  save stat_mean4_2019d stat_mean4_2019d;
   IRF_mean4_2019d(jj,:)=[ IRF]
  save IRF_mean4_2019d IRF_mean4_2019d;
    moments_sect(jj,:)=[ moments]
  save moments_sect moments_sect;

end
